package com.scau.meetingbook.controller;

import com.scau.meetingbook.dto.CancellationRequestDTO;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import com.scau.meetingbook.service.CancellationRequestsService;
import com.scau.meetingbook.pojo.CancellationRequests;
import com.scau.meetingbook.vo.ResultVO;

import java.util.List;

@RestController
@RequestMapping("/cancellationRequests")
public class CancellationRequestsController {

    @Autowired
    private CancellationRequestsService cancellationRequestsService;

    /**
     * 创建会议室取消预约申请
     * @param cancellationRequests
     * @return
     */
    @PostMapping("/createCancellationRequests")
    @ApiOperation(value = "创建会议室取消预约申请")
    public ResultVO createCancellationRequests(@RequestBody CancellationRequests cancellationRequests) throws Exception {
        return cancellationRequestsService.createCancellationRequests(cancellationRequests);
    }

    /**
     * 审核通过会议室取消预约申请
     * @param
     * @return
     */
    @PutMapping("/auditCancellationRequests")
    @ApiOperation(value = "审核通过会议室取消预约申请")
    public ResultVO auditCancellationRequests(Integer requestId) throws Exception {
        return cancellationRequestsService.auditCancellationRequests(requestId);
    }

    /**
     * 拒绝会议室取消预约申请
     * @return
     */
    @PutMapping("/rejectCancellationRequests")
    @ApiOperation(value = "拒绝会议室取消预约申请")
    public ResultVO rejectCancellationRequests(Integer requestId) throws Exception {
        return cancellationRequestsService.rejectCancellationRequests(requestId);
    }


    @PostMapping("/insertCancellationRequests")
    public ResultVO insertCancellationRequests(@RequestBody CancellationRequests cancellationRequests) throws Exception {
        return cancellationRequestsService.insertCancellationRequests(cancellationRequests);
    }

    @GetMapping("/getCancellationRequestsById")
    public ResultVO<CancellationRequests> getCancellationRequestsById(Integer id) throws Exception {
        return cancellationRequestsService.getCancellationRequestsById(id);
    }

    @PutMapping("/updateCancellationRequestsById")
    public ResultVO updateCancellationRequestsById(@RequestBody CancellationRequests cancellationRequests) throws Exception {
        return cancellationRequestsService.updateCancellationRequestsById(cancellationRequests);
    }

    @DeleteMapping("/deleteCancellationRequestsById")
    public ResultVO deleteCancellationRequestsById(Integer id) throws Exception {
        return cancellationRequestsService.deleteCancellationRequestsById(id);
    }

    @GetMapping("/cancellation-requests")
    public ResultVO<List<CancellationRequestDTO>> getAllRequests() {
        return cancellationRequestsService.getAllCancellationRequests();
    }
}